Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-0 vector-toc-not-available vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-0 vector-feature-night-mode-enabled skin-theme-clientpref-os vector-sticky-header-enabled" lang="fr" dir="ltr"><head>
<meta charset="UTF-8">
<title>WxPython</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="./_res_/favicon.png">
<link rel="canonical" href="https://fr.wikipedia.org/wiki/WxPython"> <link href="./_mw_/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.wikimediamessages.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/mediawiki.page.gallery.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./_mw_/site.styles.css">
<link rel="stylesheet" type="text/css" href="./_mw_/noscript.css">
<link rel="stylesheet" type="text/css" href="./_res_/footer.css">
<link rel="stylesheet" type="text/css" href="./_res_/vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-WxPython rootpage-WxPython skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">wxPython</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="contentSub">
<div id="mw-content-subtitle"></div>
</div>
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="fr" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="fr" dir="ltr"><p class="mw-empty-elt">
</p>
<div class="infobox_v3 infobox infobox--frwiki noarchive" style="width:260px">
<div class="entete icon informatique" style="color: #000000;"><style data-mw-deduplicate="TemplateStyles:r228712691">
/* start https://fr.wikipedia.org/ */


.mw-parser-output .entete.informatique{background-image:url("./_mw_/Picto.nfo.png")}


/* end https://fr.wikipedia.org/ */
</style>
<div>WxPython</div>
</div>
<div class="images">
</div>
<div class="hr" style="height:2px;"></div>
<div class="images">
</div>
<table><caption style="color:#000000;">Informations</caption>









<tbody><tr>
<th scope="row"> <a href="Version_d'un_logiciel" title="Version d'un logiciel">Dernière version</a>
</th>
<td>
<span class="wd_p348">4.2.3 (<time class="nowrap" datetime="2025-04-09" data-sort-value="2025-04-09">9 avril 2025</time>)<sup id="cite_ref-wikidata-6b66cd700b0e9a64ba3f586de54ce654b415d6ea_1-0" class="reference"><a href="#cite_note-wikidata-6b66cd700b0e9a64ba3f586de54ce654b415d6ea-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup></span></td>
</tr>



<tr>
<th scope="row"><a href="D%C3%A9p%C3%B4t_(informatique)" title="Dépôt (informatique)">Dépôt</a></th>
<td>
<span class="wd_p1324"><a rel="nofollow" class="external text" href="https://github.com/wxWidgets/Phoenix/">github.com/wxWidgets/Phoenix</a></span></td>
</tr>





<tr>
<th scope="row"> <a href="Langage_de_programmation" title="Langage de programmation">Écrit en</a>
</th>
<td>
<span class="wd_p277"><a href="C%2B%2B" title="C++">C++</a> et <a href="Python_(langage)" title="Python (langage)">Python</a></span></td>
</tr>





<tr>
<th scope="row"><a href="Syst%C3%A8me_d'exploitation" title="Système d'exploitation">Système d'exploitation</a></th>
<td>
<span class="wd_p306"><a href="Type_Unix" title="Type Unix">Type Unix</a></span></td>
</tr>











<tr>
<th scope="row"> Type
</th>
<td>
<span class="wd_p31">Binding C - Python <small>(<a href="https://www.wikidata.org/wiki/Q17144865" class="extiw external" title="d:Q17144865"><span class="indicateur-langue" title="Voir l'élément Wikidata correspondant">d</span></a>)</small><br><a href="Widget_toolkit" title="Widget toolkit">Widget toolkit</a><br>Bibliothèque logicielle Python <small>(<a href="https://www.wikidata.org/wiki/Q29642950" class="extiw external" title="d:Q29642950"><span class="indicateur-langue" title="Voir l'élément Wikidata correspondant">d</span></a>)</small></span></td>
</tr>



<tr>
<th scope="row"><a href="Licence_de_logiciel" title="Licence de logiciel">Licence</a></th>
<td>
<span class="wd_p275">Licence de logiciel libre <small>(<a href="https://en.wikipedia.org/wiki/Free-software_license" class="extiw external" title="en:Free-software license"><span class="indicateur-langue" title="Article sur Wikipédia en anglais">en</span></a>)</small> et <a href="Licence_publique_g%C3%A9n%C3%A9rale_GNU" title="Licence publique générale GNU">licence publique générale GNU</a></span></td>
</tr>



<tr>
<th scope="row"><a href="Site_web" title="Site web">Site web</a></th>
<td>
<span class="wd_p856"><a rel="nofollow" class="external text" href="https://wxpython.org/">wxpython.org</a></span></td>
</tr>

</tbody></table>
<p class="mw-empty-elt">

</p>
</div>
<p><b>wxPython</b> est une implémentation libre en <a href="Python_(langage)" title="Python (langage)">Python</a> de l'<a href="Interface_de_programmation" title="Interface de programmation">interface de programmation</a> <a href="WxWidgets" title="WxWidgets">wxWidgets</a>. Cette bibliothèque Python est utilisée pour la création d'<a href="Interface_graphique" title="Interface graphique">interfaces graphiques</a>, et est l'alternative de <a href="Tkinter" title="Tkinter">Tkinter</a> la plus utilisée.
</p><p>wxPython est <a href="Multiplate-forme" class="mw-redirect" title="Multiplate-forme">multiplate-forme</a>, et le même logiciel peut être exécuté sur <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a>, <a href="UNIX" class="mw-redirect" title="UNIX">UNIX</a> et apparentés, et <a href="MacOS" title="MacOS">MacOS</a> sans modification. Pour la création et gestion des <a href="Composant_d'interface_graphique" title="Composant d'interface graphique">widgets</a>, l'interface de programmation du <a href="Syst%C3%A8me_d'exploitation" title="Système d'exploitation">système d'exploitation</a> hôte est utilisée le plus possible, ce qui donne une apparence native à l'application.
</p><p>wxPython essaie d'unir la simplicité et la lecture facile de Python avec une <a href="Interface_de_programmation" title="Interface de programmation">interface de programmation</a> très complète. Ceci donne un <a href="Cycle_de_d%C3%A9veloppement_(logiciel)" title="Cycle de développement (logiciel)">cycle de développement</a> rapide tout en permettant une grande complexité si nécessaire.
</p><p>Pour pouvoir utiliser les logiciels qui utilisent cette bibliothèque, il est d'abord nécessaire de la télécharger et de l'installer sur le système, en plus de l'installation de Python, à moins de recevoir le logiciel sous forme de <a href="Fichier_binaire" title="Fichier binaire">fichiers binaires</a>.
</p>

<div class="mw-heading mw-heading2"><h2 id="Histoire">Histoire</h2></div>
<p>wxPython est né quand Robin Dunn eut besoin d'une <a href="Interface_utilisateur_graphique" class="mw-redirect" title="Interface utilisateur graphique">interface utilisateur graphique</a> qui devait être déployée sous <a href="HP-UX" title="HP-UX">HP-UX</a> et aussi <a href="Windows_3.1" title="Windows 3.1">Windows 3.1</a> en quelques semaines. Pendant l'évaluation de solutions commerciales, il trouva des <a href="Binding" title="Binding">bindings</a> en Python pour la boite à outils wxWidgets. Donc il apprit Python et, bientôt, devint un des principaux <a href="D%C3%A9veloppeur" title="Développeur">développeurs</a> de wxPython (qui grandit de ces bindings d'origine), avec Harri Pasanen.
Les premières versions du <a href="Adaptateur" title="Adaptateur">wrapper</a> étaient codées à la main mais le <a href="Code_source" title="Code source">code</a> devint rapidement très difficile à garder synchronisé avec les versions de wxWidgets. Par contre, les versions plus récentes sont créées avec <a href="SWIG" title="SWIG">SWIG</a>, ce qui réduit considérablement le travail nécessaire aux mises à jour. La première version «&nbsp;moderne&nbsp;» fut annoncée en 1998<a rel="nofollow" class="external autonumber" href="http://groups.yahoo.com/group/python-announce-list/message/95">[1]</a>(en).
</p>
<div class="mw-heading mw-heading2"><h2 id="Licence">Licence</h2></div>
<p>wxPython est publié sous la licence <a rel="nofollow" class="external text" href="http://www.opensource.org/licenses/wxwindows.php/">wxWindows Library</a>, qui est basée sur la <a href="LGPL" class="mw-redirect" title="LGPL">LGPL</a> mais qui permet la distribution d'œuvres dérivées sous n'importe quelle licence.
</p>
<div class="mw-heading mw-heading2"><h2 id="Exemple">Exemple</h2></div>
<div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="ch">#!/usr/bin/env python</span>
<span class="c1"># -*- coding: utf-8 -*-</span>

<span class="c1"># Importation du paquet wxPython</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">wx</span>

<span class="c1"># Création d'un nouveau cadre, dérivé du wxPython 'Frame'.</span>
<span class="k">class</span><span class="w"> </span><span class="nc">TestFrame</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">Frame</span><span class="p">):</span>
<span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parent</span><span class="p">,</span> <span class="n">ID</span><span class="p">,</span> <span class="n">title</span><span class="p">):</span>
<span class="n">wx</span><span class="o">.</span><span class="n">Frame</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parent</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">pos</span><span class="o">=</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">100</span><span class="p">))</span>

<span class="c1"># À l'intérieur du cadre, créer un panneau..</span>
<span class="n">panel</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">Panel</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>

<span class="c1"># Créer un texte dans le panneau</span>
<span class="n">texte</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">panel</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s2">"Bonjour tout le monde!"</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="n">wx</span><span class="o">.</span><span class="n">Size</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">))</span>
<span class="c1"># Créer un bouton dans le panneau</span>
<span class="n">bouton</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">Button</span><span class="p">(</span><span class="n">panel</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s2">"Cliquez-moi!"</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">35</span><span class="p">),</span> <span class="n">wx</span><span class="o">.</span><span class="n">Size</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">))</span>
<span class="c1"># lier le bouton à une fonction:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_BUTTON</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">creerDiag</span><span class="p">,</span> <span class="n">bouton</span><span class="p">)</span>
<span class="c1"># fonction qui affiche une boîte de dialogue</span>
<span class="k">def</span><span class="w"> </span><span class="nf">creerDiag</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
<span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">MessageDialog</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"Merci de m'avoir cliqué, ça fait du bien."</span><span class="p">,</span>
<span class="s2">"Merci!"</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">ICON_EXCLAMATION</span> <span class="o">|</span> <span class="n">wx</span><span class="o">.</span><span class="n">YES_NO</span> <span class="o">|</span> <span class="n">wx</span><span class="o">.</span><span class="n">CANCEL</span><span class="p">)</span>
<span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span>
<span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>

<span class="c1"># Chaque application wxWidgets doit avoir une classe dérivée de wx.App</span>
<span class="k">class</span><span class="w"> </span><span class="nc">TestApp</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">App</span><span class="p">):</span>
<span class="k">def</span><span class="w"> </span><span class="nf">OnInit</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">frame</span> <span class="o">=</span> <span class="n">TestFrame</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s2">"Test"</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">SetTopWindow</span><span class="p">(</span><span class="n">frame</span><span class="p">)</span>
<span class="n">frame</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
<span class="k">return</span> <span class="kc">True</span>

<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">'__main__'</span><span class="p">:</span>
<span class="n">app</span> <span class="o">=</span> <span class="n">TestApp</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># créer une nouvelle instance de l'application</span>
<span class="n">app</span><span class="o">.</span><span class="n">MainLoop</span><span class="p">()</span> <span class="c1"># lancer l'application</span>
</pre></div>
<p>En voici le résultat:
</p>
<ul class="gallery mw-gallery-traditional">
<li class="gallerybox" style="width: 155px">
<div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File"></span></div>
<div class="gallerytext">Le résultat, sous <span class="nowrap"><a href="Windows_XP" title="Windows XP">Windows XP</a></span></div>
</li>
<li class="gallerybox" style="width: 155px">
<div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File"></span></div>
<div class="gallerytext">Le résultat, sous Linux et <a href="GNOME" title="GNOME">GNOME</a></div>
</li>
<li class="gallerybox" style="width: 155px">
<div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File"></span></div>
<div class="gallerytext">Le résultat, sous Linux et <a href="MATE" title="MATE">MATE</a> (thème sombre)</div>
</li>
</ul>
<div class="mw-heading mw-heading2"><h2 id="Références"><span id="R.C3.A9f.C3.A9rences"></span>Références</h2></div>
<div class="references-small decimal" style=""><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-wikidata-6b66cd700b0e9a64ba3f586de54ce654b415d6ea-1"><span class="mw-cite-backlink"><a href="#cite_ref-wikidata-6b66cd700b0e9a64ba3f586de54ce654b415d6ea_1-0">↑</a> </span><span class="reference-text"><span class="ouvrage">«&nbsp;<a rel="nofollow" class="external text" href="https://wxpython.org/news/2025-04-09-wxpython-423-release/"><cite style="font-style:normal;">https://wxpython.org/news/2025-04-09-wxpython-423-release/</cite></a>&nbsp;»</span></span>
</li>
</ol></div>
</div>
<div class="mw-heading mw-heading2"><h2 id="Liens_externes">Liens externes</h2></div>
<ul><li><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> <a rel="nofollow" class="external text" href="http://www.wxpython.org/">Site Officiel de wxPython</a></li>
<li><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> <a rel="nofollow" class="external text" href="http://www.wxwidgets.org/">Site Officiel de wxWidgets</a></li>
<li><a rel="nofollow" class="external text" href="http://sebsauvage.net/python/gui/index_fr.html">Construire une interface graphique pas à pas avec TkInter et wxPython</a></li></ul>

<ul id="bandeau-portail" class="bandeau-portail"><li><span class="bandeau-portail-element"><span class="bandeau-portail-icone"><span class="noviewer" typeof="mw:File"></span></span> <span class="bandeau-portail-texte">Portail des logiciels libres</span> </span></li> <li><span class="bandeau-portail-element"><span class="bandeau-portail-icone"><span class="noviewer" typeof="mw:File"></span></span> <span class="bandeau-portail-texte">Portail de l’informatique</span> </span></li> <li><span class="bandeau-portail-element"><span class="bandeau-portail-icone"><span class="noviewer" typeof="mw:File"></span></span> <span class="bandeau-portail-texte">Portail de la programmation informatique</span> </span></li> </ul></div><!--htdig_noindex--><div><div class="zim-footer">
Cet article est issu de <a class="external text" title="Dernière modification le 2024-02-12" href="https://fr.wikipedia.org/wiki/?title=WxPython&amp;oldid=212382811">Wikipédia</a>. Sauf mention contraire, le texte est disponible sous <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.fr">Creative Commons Attribution-Share Alike 4.0</a>. Des conditions supplémentaires peuvent s’appliquer aux fichiers multimédias.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
<script src="./_webp_/webpHandler.js"></script>

</body></html>